package com.iman.fetion.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.iman.fetion.FetionMessage;

/**
 * Servlet implementation class PicCodeServlet
 */
public class PicCodeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PicCodeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		FetionMessage fetion=new FetionMessage();
		fetion.getPicCode();
		String picId=fetion.picId;
		String picContent=fetion.picContent;
		response.setContentType("text/xml");
		PrintWriter out = response.getWriter();
		
		System.out.println("Get PicCode="+getXml(picId,picContent));
		
		out.write(getXml(picId,picContent));
		out.flush();
		out.close();
	}

	
	private String getXml(String picId,String picContent){
		String xml="<result>";
		xml+="<picId>"+picId+"</picId>";
		xml+="<picContent>"+picContent+"</picContent>";		
		xml+="</result>";
		return xml;
	}

}
